const path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin');
const {VueLoaderPlugin} = require('vue-loader')
const Mock = require("mockjs")
var data = Mock.mock({
    "list|5": [{
        "tit": "@ctitle",
        "img": "@Image(375x100,@color)"
    }]
}).list
module.exports = {
    mode: "development",
    entry: './src/index.js', //入口
    output: { // 出口
        path: path.join(__dirname, 'dist'),
        filename: 'dist.js'
    },
    module: {
        rules: [{
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            },
        ]
    },
    // plugins放插件
    plugins: [new HtmlWebpackPlugin({
            template: "./src/index.html",
            filename: "index.html"
        }),
        new VueLoaderPlugin()


    ],
    devServer: {
        host: "127.0.0.1",
        port: 7777,
        hot: true,
        open: true,
        before(app) {
            app.get("/list", (req, res) => {
                res.send(data)
            })
        }
    }
};